package cn.dckeji.dcssm.common.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;

/**
 * @program: dcssm
 * @description: 接口返回分页结果对象
 * @author: kenny sun
 * @create: 2019-07-18 09:45
 */
@ApiModel("分页对象")
public class ResultPageModel<T> {

    @ApiModelProperty("是否成功:成功状态码10200")
    private Integer code;
    @ApiModelProperty("描述性原因")
    private String message;
    @ApiModelProperty("业务数据")
    private List<T> data;
    @ApiModelProperty("总条数")
    private long total;

    private ResultPageModel(Integer code, String message, List<T> data,long total) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.total = total;
    }

    public static <T>ResultPageModel page(long total, List<T> data, String message) {

        ResultPageModel<T> resultPageModel = new ResultPageModel(10200, message, data, total);

        return resultPageModel;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }
}